// 公共参数
import { PROTOCOL, HOST, PORT } from './base'
const baseURL = `${PROTOCOL}://${HOST}:${PORT}`
import axios from "axios"

// 登陆
export const loginFunc = (url, data = {}, option = { headers: "application/x-www-form-urlencoded" }) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 注册
export const registerFunc = (url, data = {}, option = { headers: "application/x-www-form-urlencoded" }) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}
// 修改用户信息
export const modifyFunc = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取用户信息
export const getuserinfor = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取手机列表数据
export const getPhoneList = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取对应手机信息
export const getPhoneinfor = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取对应手机配置信息
export const getPhoneconfig = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取对应电视信息
export const getTVinfor = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取对应电视配置信息
export const getTVconfig = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
//添加收货地址
export const addressuser = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
//添加购物车
export const usershopcart = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
//添加用户订单
export const userOrder = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}

// 发送验证码
export const sendEmailFunc = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
// 获取广告列表
export const getAdvertList = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}
// 上传头像到后台
export const uploadImageFunc = (url, data,headers) => {
    // 使用axios上传图片
    return axios.post(`${baseURL}${url}`, data, {
        headers
    })
        .then(
            response => {
                return response.data;
            }
        )
}
// 把图片路径上传到数据库
export const imgsqlFunc = (url, data = {}) => {
    return axios.get(`${baseURL}${url}`, { params: data })
        .then(
            response => {
                return response.data;
            }
        )
}
// 是否在线
export const isLogin = (url, data = {}, option = { headers: "application/x-www-form-urlencoded" }) => {
    return axios.post(`${baseURL}${url}`, data, option)
        .then(
            response => {
                return response.data;
            }
        )
}

// 获取tab分类列表
export const getAboutList = (url) => {
    return axios.get(`${baseURL}${url}`)
        .then(
            response => {
                return response.data;
            }
        )
}
